import sys
sys.path.append("..")
from database.db_handler import MysqlHander
from common.my_http import MyHttp
import urllib.request
from bs4 import BeautifulSoup
from common.entity_data import EntityData
import glob
import jieba
import re
import threading
import hashlib
import time

'''
检察院
'''

class NgoZhongguoData:
    def __init__(self):
        #self.entity = EntityData()
        self.diqu_url = {}
        pass
    
    def get_url_list(self):
        value_all = ""
        for i in range (1,33):
            url = "http://baike.lvngo.com/baike/chinango/index.php?page=" + str(i)
            print(url)
            time.sleep(1)
            bs4_data = MyHttp.bs4_utf8_data(url, 10000)
            for dl in bs4_data.find_all(name="dl", attrs={'class':'bbda'}):
                value = dl.find("a").text.split("-")[0]
                value_all += "|" + value
                
        print(value_all)
        #self.entity.add_entity_data("中国内地检察院", "", 100, 1010001, "", "", value_all)
        #self.entity.update_entity_data("中国内地检察院", "", 100, 1010001, "", "", value_all)

    
    def get_data(self):
        self.get_url_list()

        

def ngo_zhongguo_api():
    d = NgoZhongguoData()
    d.get_data()

if __name__ == '__main__':
    ngo_zhongguo_api()
